﻿Public Class WindowVariablesTypesRequest

    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub

    Public Shared Sub Fill(ByRef _variablesTypesRequest As Enhancements.Basic.Expressions.CompilerExpressionVariablesTypesRequestEventArgs)
        Dim _window As WindowVariablesTypesRequest = New WindowVariablesTypesRequest()

        For Each _variable As Enhancements.Basic.Expressions.CompilerExpressionVariablesTypesRequestEventArgsVariable In _variablesTypesRequest.Variables

            Dim _uniformgrid As Primitives.UniformGrid = New Primitives.UniformGrid
            _uniformgrid.Columns = 2

            Dim _nameLabel As Label = New Label()
            _nameLabel.Content = _variable.Name
            _nameLabel.Padding = Nothing
            _nameLabel.Background = Nothing
            _nameLabel.Foreground = New SolidColorBrush(Colors.White)
            _nameLabel.VerticalContentAlignment = Windows.VerticalAlignment.Center
            _uniformgrid.Children.Add(_nameLabel)

            Dim _typeCombobox As ComboBox = New ComboBox()
            _typeCombobox.IsReadOnly = True
            _typeCombobox.Items.Clear()
            For Each _supportedValueType As Type In Enhancements.Basic.Expressions.Compiler.SupportedValuesTypes
                _typeCombobox.Items.Add(_supportedValueType.Name)
            Next _supportedValueType
            _typeCombobox.SelectedIndex = 0
            _uniformgrid.Children.Add(_typeCombobox)

            _window.__VariablesArea.Children.Add(_uniformgrid)

        Next _variable

        _window.ShowDialog()

        For _counter As Integer = 0 To _variablesTypesRequest.Variables.Length - 1
            _variablesTypesRequest.Variables(_counter).Type = Enhancements.Basic.Expressions.Compiler.SupportedValuesTypes(CType(CType(_window.__VariablesArea.Children(_counter), Primitives.UniformGrid).Children(1), ComboBox).SelectedIndex)
        Next _counter
    End Sub

    Private Sub __OkButton_Click(ByVal _sender As Object, ByVal _arguments As System.Windows.RoutedEventArgs) Handles __OkButton.Click
        Me.Close()
    End Sub

End Class
